﻿using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class GameMaster : MonoBehaviour {

	public int Death = 0;
	public int LevelCount = 2;
	int Level = 1;
	
	//UI
	Text Text_Death;
	Text Text_Level;

	void Awake() {
		DontDestroyOnLoad (this);
		this.Text_Death = GameObject.Find("Death").GetComponent<Text>();
		this.Text_Level = GameObject.Find("Level").GetComponent<Text>();
	}

	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
	
	}

	public void OnPlayerDeath(){
		Death ++;
		Text_Death.text = "DEATHS: " + Death;
	}

	public void LoadLevel(int level){
		Application.LoadLevel ("level-" + level);
	}

	public void ClearScene(){
		Application.LoadLevel ("Clear");
	}

	public void LoadNextLevel(){
		if (this.Level + 1 <= LevelCount) {
			LoadLevel (this.Level + 1);
		} else {
			ClearScene();
		}
	}

	public void OnLevelStart(int level){
		this.Level = level;
		Text_Level.text = level + "/" + LevelCount;
	}
}
